<?php
	/**
	 * 
	 * @param unknown_type $pMerBillNo
	 * @return string
	 */

	function BindBankCard($user_id,$platformNo,$post_url){
	
		$pWebUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=response&class_name=fuioupay&class_act=BindBankCard";//web方式返回
		//$pS2SUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=notify&class_name=fuioupay&class_act=BindBankCard&from=".$_REQUEST['from'];//s2s方式返回		
		
		$user = array();
		$user = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$user_id);
		
		$fuioupay_log = array();
		$fuioupay_log['code'] = 'toBindBankCard';
		$fuioupay_log['create_date'] = to_date(TIME_UTC,'Y-m-d H:i:s');
		$GLOBALS['db']->autoExecute(DB_PREFIX."fuioupay_log",$fuioupay_log);
		$requestNo = $GLOBALS['db']->insert_id();
		
		
		$Sign_data = array();
		$Sign_data['login_id'] = $user['mobile'];//请求流水号
		$Sign_data['mchnt_cd'] = $platformNo;//
		$Sign_data['mchnt_txn_ssn'] = $user['id'].time();//请求流水号
		$Sign_data['page_notify_url'] = $pWebUrl;// 商户返回地址
		//login_id + "|" + mchnt_cd + "|" + mchnt_txn_ssn + "|"+ page_notify_url
		ksort($Sign_data);
		foreach($Sign_data as $k => $v){
			if($k == 'page_notify_url'){
				$Sign_old .=$v;
				$Sign_old_a .=$k;
			}else{
				$Sign_old .= $v."|";
				$Sign_old_a .= $k."+|+";
			}
		}
		print_r($Sign_old);echo "<hr/>";
		print_r($Sign_old_a);echo "<hr/>";	
		$pSign=rsaSign($Sign_old,PRIVATE_KEY_PATH);
		
		$strhtml = '';
		foreach($Sign_data as $k => $v){
			$strhtml .= '<input type="hidden" name="'.$k.'" value="'.$v.'" /><br/>';
		}
				
		$html = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /></head><body>
		<form name="form1" id="form1" method="post" action="'.$post_url.'" target="_self">		
		<input type="hidden" name="signature" value="'.$pSign.'" />		
		'.$strhtml.'
	 	<input type="hidden" value="提交" />
	 	<div style="width:100%;text-align:center;padding:50px 0;"><img src="'.APP_ROOT.'/app/Tpl/'.app_conf("TEMPLATE").'/images/loading.gif" />页面正在跳转，请稍后...</div>
		</form>
		</body></html>
		<script language="javascript">document.form1.submit();</script>';
		
		$fuioupay_log = array();
		$fuioupay_log['html'] = $html;
		$GLOBALS['db']->autoExecute(DB_PREFIX."fuioupay_log",$fuioupay_log,'UPDATE','id='.$requestNo);
		
		return $html;
	}
	
	
	function BindBankCardCallBack($str3Req){
		$mchnt_txn_ssn = $str3Req["mchnt_txn_ssn"];
		if($mchnt_txn_ssn){
			unset($str3Req["mchnt_txn_ssn"]);
		}
		if($str3Req["code"]=='0000'){
			return 1;
		}else{
			return 0;
		}
	}	
	
?>